//
//  CYModelConfig.m
//  CaiYun
//
//  Created by 今日信息科技 on 2017/9/28.
//  Copyright © 2017年 今日信息科技. All rights reserved.
//

#import "CYModelConfig.h"
@implementation CYModelConfig
+ (void)load{
    
    NSArray *array = @[@"CYRechergeModel",@"CYTotalRechargeModel", @"CYUser",@"CYShopCartLotteryModel",@"CYLotteryModel",@"CYFirstSubBetModel"];
    for (NSString *string in array) {
        [NSClassFromString(string) mj_setupReplacedKeyFromPropertyName:^NSDictionary *{
            return @{@"ID":@"id",
                     @"codes":@"code",
                     @"descrip":@"description",
                     @"className":@"class_name",
                     @"codeList":@"code_list",
                     @"fanDianMax":@"fan_dian_max",
                     @"groupName":@"group_name",
                     @"seconSubBetArr":@"children"};
        }];
        
        [NSClassFromString(string) mj_setupReplacedKeyFromPropertyName121:^id(NSString *propertyName) {
            if ([propertyName isEqualToString:@"ID"]) return @"id";
            if ([propertyName isEqualToString:@"action_No"]) return @"action_No";//投注的期号，API需要期号参数key为@"action_No",这里不需要转换成actionNo，否则请求投注的时候，又要转换回action_No
            else if ([propertyName isEqualToString:@"seconSubBetArr"]) return @"children";
            return [propertyName mj_underlineFromCamel];
        }];
        
    }
    
    
    //CYBetModel
    [NSClassFromString(@"CYBetModel") mj_setupReplacedKeyFromPropertyName:^NSDictionary *{
        return @{@"ID":@"gemData.id",
                 @"fanDianMax":@"fanDianMax",
                 @"actionNo":@"gemData.action_no",
                 @"endTime":@"gemData.end_time",
                 @"actionTime":@"gemData.action_time",
                 @"name":@"gemData.name",
                 @"codeList":@"gemData.code_list",
                 @"playedGroupId":@"gemData.played_group_id",
                 @"firstSubBetArr":@"playedGroupData"};
    }];
    
    [NSClassFromString(@"CYBetModel") mj_setupReplacedKeyFromPropertyName121:^id(NSString *propertyName) {
        if ([propertyName isEqualToString:@"ID"]) return @"gemData.id";
        else if ([propertyName isEqualToString:@"actionNo"]) return @"gemData.action_no";
        else if ([propertyName isEqualToString:@"endTime"]) return @"gemData.end_time";
        else if ([propertyName isEqualToString:@"actionTime"]) return @"gemData.action_time";
        else if ([propertyName isEqualToString:@"codeList"]) return @"gemData.code_list";
        else if ([propertyName isEqualToString:@"playedGroupId"]) return @"gemData.played_group_id";
        else if ([propertyName isEqualToString:@"firstSubBetArr"]) return @"playedGroupData";
        else if ([propertyName isEqualToString:@"fanDianMax"]) return @"fanDianMax";
        return [propertyName mj_underlineFromCamel];
    }];
    
    [NSClassFromString(@"CYBetModel") mj_setupObjectClassInArray:^NSDictionary *{
        return @{@"firstSubBetArr":@"CYFirstSubBetModel"};
    }];
    //end
    
    
    /*****模型有一个数组属性，数组中装载另一个模型，需要制定该子模型的类型***/
    //购物车
    //CYShopCartLotteryModel
    [NSClassFromString(@"CYShopCartLotteryModel") mj_setupObjectClassInArray:^NSDictionary *{
        return @{@"codes":@"CYSelectLotteryModel"};
    }];
    
    //CYFirstSubBetModel
    [NSClassFromString(@"CYFirstSubBetModel") mj_setupObjectClassInArray:^NSDictionary *{
        return @{@"seconSubBetArr":@"CYSecondSubBetModel"};
    }];
    //end
    
    //CYSecondSubBetModel
    
    [NSClassFromString(@"CYSecondSubBetModel") mj_setupReplacedKeyFromPropertyName:^NSDictionary *{
        return @{@"ID":@"id",
                 @"bonusProp":@"bonus_prop",
                 @"bonusPropBase":@"bonus_prop_base",
                 @"maxCount":@"max_count",
                 @"minCharge":@"min_charge",
                 @"selectNum":@"select_num",
                 @"simpleInfo":@"simple_info",
                 @"playedTpl":@"played_tpl"};
    }];
    
    [NSClassFromString(@"CYSecondSubBetModel") mj_setupReplacedKeyFromPropertyName121:^id(NSString *propertyName) {
        if ([propertyName isEqualToString:@"ID"]) return @"id";
        if ([propertyName isEqualToString:@"gatherArr"]) return @"gatherArr";
        return [propertyName mj_underlineFromCamel];
    }];
    
    [NSClassFromString(@"CYSecondSubBetModel") mj_setupObjectClassInArray:^NSDictionary *{
        return @{@"gatherArr":@"CYLeastModel"};
    }];
    //end
    
    //CYLeastModel
    [NSClassFromString(@"CYLeastModel") mj_setupReplacedKeyFromPropertyName:^NSDictionary *{
        return @{@"bonusProp":@"bonus_prop",
                 @"bonusPropBase":@"bonus_prop_base"};
    }];
    //end
    
    
    //CYCurrentBetModel
    
    [NSClassFromString(@"CYCurrentBetModel") mj_setupObjectClassInArray:^NSDictionary *{
        return @{@"gatherArr":@"CYLeastModel"};
    }];
    //end
    
    
    //CYLotteryNoticeModel
    [NSClassFromString(@"CYLotteryNoticeModel") mj_setupReplacedKeyFromPropertyName:^NSDictionary *{
        return @{@"action_data":@"action_data.data",
                 @"ID":@"id"};
    }];
    [NSClassFromString(@"CYLotteryNoticeModel") mj_setupReplacedKeyFromPropertyName121:^id(NSString *propertyName) {
        if ([propertyName isEqualToString:@"ID"]) return @"id";
        return [propertyName mj_underlineFromCamel];
    }];
    //end
    
    //CYTotalLotteryNoticeModel
    [NSClassFromString(@"CYTotalLotteryNoticeModel") mj_setupObjectClassInArray:^NSDictionary *{
        return @{@"notices":@"CYLotteryNoticeModel"};
    }];
    //end
    
    //CYLotteryWinModel
    [NSClassFromString(@"CYLotteryWinModel") mj_setupReplacedKeyFromPropertyName:^NSDictionary *{
        return @{@"ID":@"information.id",
                 @"identifying":@"information.identifying",
                 @"name":@"information.name",
                 @"lotteries":@"lottery"};
    }];
    [NSClassFromString(@"CYLotteryWinModel") mj_setupObjectClassInArray:^NSDictionary *{
        return @{@"lotteries":@"CYWinNumberModel"};
    }];
    //end
    
    //CYAccountDetailModel
    [NSClassFromString(@"CYAccountDetailModel") mj_setupReplacedKeyFromPropertyName:^NSDictionary *{
        return @{@"recordModels":@[@"user_cash",@"UserRecharge",@"AccountLists"]};
    }];
    
    [NSClassFromString(@"CYAccountDetailModel") mj_setupObjectClassInArray:^NSDictionary *{
        return @{@"recordModels":@"CYRecordModel"};
    }];
    //end
    
    //CYRecordModel
    [NSClassFromString(@"CYRecordModel") mj_setupReplacedKeyFromPropertyName:^NSDictionary *{
        return @{@"money":@[@"amount",@"money"]};
    }];
    //end

    //CYTrendModel
    [NSClassFromString(@"CYTrendModel") mj_setupObjectClassInArray:^NSDictionary *{
        return @{@"data":@"CYWinModel"};
    }];
    //end
    
    //CYTotalOrderModel
    [NSClassFromString(@"CYTotalOrderModel") mj_setupObjectClassInArray:^NSDictionary *{
        return @{@"bets_data":@"CYOrderModel"};
    }];
    //end

    //CYOrderModel
    [NSClassFromString(@"CYOrderModel") mj_setupReplacedKeyFromPropertyName:^NSDictionary *{
        return @{@"ID":@"id"};
    }];
    
    [NSClassFromString(@"CYOrderModel") mj_setupReplacedKeyFromPropertyName121:^id(NSString *propertyName) {
        if ([propertyName isEqualToString:@"ID"]) return @"id";
        return [propertyName mj_underlineFromCamel];
    }];
    //end
    
}
@end
